package com.rich.dmr.ui.activity;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.widget.Toast;

import com.rich.dmr.R;
import com.rich.dmr.ui.fragment.ChannelFragment;
import com.rich.dmr.ui.fragment.GroupContactFragment;
import com.rich.dmr.ui.fragment.RxGroupFragment;

import java.util.ArrayList;
import java.util.List;

import me.relex.circleindicator.CircleIndicator;
import rich.dmr.DmrManager;


public class ListShowActivity extends AppCompatActivity {
    private String TAG = "rich---ListShowActivity";
    private DmrManager dmrManager;

    @SuppressLint({"WrongConstant", "ClickableViewAccessibility"})
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_show);
        dmrManager = (DmrManager) getSystemService("dmrservice");
        ArrayList<Fragment> list = new ArrayList<>();
        list.add(new GroupContactFragment());
        list.add(new RxGroupFragment());
        CircleIndicator circleIndicator;
        circleIndicator = findViewById(R.id.list_show_strategy_indicator);
        ViewPager viewPager = findViewById(R.id.list_show_viewpager);
        viewPager.setAdapter(new ListShowActivity.ViewPagerAdapter(getFragmentManager(), list));
        circleIndicator.setViewPager(viewPager);
        viewPager.setCurrentItem(0);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }


    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    public class ViewPagerAdapter extends FragmentPagerAdapter {
        List<Fragment> fragmentList;

        public ViewPagerAdapter(FragmentManager fm, List<Fragment> list) {
            super(fm);
            fragmentList = list;
        }

        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getCount() {
            return fragmentList.size();
        }
    }
}
